<?php

require_once 'AbstractService.php';


/**
 * 查询信息模板
 * Class QueryContactTemplateService
 * time 2020/11/11 12:44
 * author zrone <xujining415@gmail.com>
 * copyright zrone <xujining415@gmail.com>
 */
class QueryContactTemplateService extends AbstractService
{
    public function __invoke(array $logicParams)
    {
        $result = $this->terminal($logicParams, 'QueryContactTemplate');
        if (isset($result["ContactTemplates"])) {
            $html = <<<EOL
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
table,table tr th, table tr td { border:1px solid #0094ff; }
table { border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr>
<td>模板 ID:</td>
<td>创建时间</td>
<td>更新时间</td>
<td>用户 ID</td>
<td>认证状态</td>
<td>注册类型</td>
<td>中文姓名</td>
<td>英文姓名</td>
<td>中文持有者姓名</td>
<td>英文所有者姓名</td>
<td>国家代码</td>
<td>中文省份</td>
<td>英文省份</td>
<td>中文城市</td>
<td>英文城市</td>
<td>中文街道</td>
<td>英文街道</td>
<td>电子邮箱</td>
<td>邮政编码</td>
<td>电话号码</td>
<td>分机号码</td>
</tr>
EOL;

            foreach($result["ContactTemplates"]['ContactTemplate'] as $contactTemplate) {
                $html .= '<tr>';
                $html .= '<td>' . $contactTemplate['ContactTemplateId'] . '</td>';
                $html .= '<td>' . $contactTemplate['CreateTime'] . '</td>';
                $html .= '<td>' . $contactTemplate['UpdateTime'] . '</td>';
                $html .= '<td>' . $contactTemplate['UserId'] . '</td>';
                $html .= '<td>' . $contactTemplate['AuditStatus'] . '</td>';
                $html .= '<td>' . $contactTemplate['RegType'] . '</td>';
                $html .= '<td>' . $contactTemplate['CName'] . '</td>';
                $html .= '<td>' . $contactTemplate['EName'] . '</td>';
                $html .= '<td>' . $contactTemplate['CCompany'] . '</td>';
                $html .= '<td>' . $contactTemplate['ECompany'] . '</td>';
                $html .= '<td>' . $contactTemplate['CCountry'] . '</td>';
                $html .= '<td>' . $contactTemplate['CProvince'] . '</td>';
                $html .= '<td>' . $contactTemplate['EProvince'] . '</td>';
                $html .= '<td>' . $contactTemplate['CCity'] . '</td>';
                $html .= '<td>' . $contactTemplate['ECity'] . '</td>';
                $html .= '<td>' . $contactTemplate['CVenu'] . '</td>';
                $html .= '<td>' . $contactTemplate['EVenu'] . '</td>';
                $html .= '<td>' . $contactTemplate['Email'] . '</td>';
                $html .= '<td>' . $contactTemplate['PostalCode'] . '</td>';
                $html .= '<td>+' . $contactTemplate['TelArea'] . ' ' . $contactTemplate['TelMain'] . '</td>';
                $html .= '<td>' . (isset($contactTemplate['TelExt']) ?? '') . '</td>';
                $html .= '</tr>';
            }
            $html .= '</table></body></html>';
            echo $html;
        } else {
            echo "请求失败，请刷新重试!";
        }
    }
}